#ifndef ML_MATERIAL_H
#define ML_MATERIAL_H

#ifdef JMBC_INSIDE

#include <Core/clCore.h>

typedef struct
{
	int magic;
	unsigned int frames;
	unsigned int actions;
} MLMaterialHeader;

typedef struct
{
	wchar_t texture[TL_STRING_DEFAULT_FIXED_SIZE];
	float alpha;
	float ambient[3];
	float diffuse[3];
	float specular[3];
	float emission[3];
	float shininess;
} MLMaterialProperties;

typedef struct
{
	float matrix[16];
} MLMaterialFrame;

typedef struct
{
	wchar_t name[TL_STRING_DEFAULT_FIXED_SIZE];
	unsigned int start;
	unsigned int frames;
} MLMaterialAction;

#define ML_MATERIAL_GROUP_PROPERTIES 0
#define ML_MATERIAL_GROUP_FRAMES 1
#define ML_MATERIAL_GROUP_ACTIONS 2

typedef struct
{
	unsigned int groups[3];
	unsigned int action, frame, texture;
} MLMaterial;

#endif


// Context

void
mlMaterialCreateContext(void);

// Generation / Deletion

void
mlGenMaterials(unsigned int n, unsigned int *materials);

void
mlDeleteMaterials(unsigned int n, unsigned int *materials);

// Load / Unload

void
mlMaterialLoad(unsigned int id, unsigned int filepath);

void
mlMaterialUnload(unsigned int id);

void
mlMaterialsUnload(unsigned int n, unsigned int *materials);

// Operation

void
mlMaterialCompile(unsigned int id, unsigned int filepath);

void
mlMaterialDecompile(unsigned int id, unsigned int filepath);

unsigned int
mlMaterialFrames(unsigned int id);

unsigned int
mlMaterialActions(unsigned int id);

unsigned int
mlMaterialAction(unsigned int id, unsigned int name);

unsigned int
mlMaterialActionFrames(unsigned int id, unsigned int action);

void
mlMaterialActionSet(unsigned int id, unsigned int action);

void
mlMaterialActionFrameSet(unsigned int id, unsigned int frame);

float *
mlMaterialMatrix(unsigned int id);

/*
float
mlMaterialAlpha(unsigned int id);
*/

// Disk I/O

void
mlMaterialSave(unsigned int id, unsigned int filepath);

// OpenGL Integration

void
mlMaterialGenTextures(unsigned int id, unsigned int path);

void
mlMaterialDeleteTextures(unsigned int id);

void
mlMaterialBind(unsigned int id);

#endif
